<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>交易流水</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="{{asset('/layuiadmin/layui/css/layui.css')}}" media="all">
<link rel="stylesheet" href="{{asset('/layuiadmin/style/admin.css')}}" media="all">
<style>
.edit{background-color: #ed9c3a;}
.shenhe{background-color: #429488;}
.see{background-color: #7cb717;}
.tongbu{background-color: #4c9ef8;color:#fff;border-radius:3.5px}
.cur{color:#21c4f5;}
.userbox,.storebox{
  height:190px;margin-right:0;
  overflow-y: auto;
  z-index: 999;
  position: absolute;
  left: 0px;
  top: 63px;
  width:298px;
  background-color:#ffffff;
  border: 1px solid #ddd;
}
.userbox .list,.storebox .list{
  height:38px;line-height: 38px;cursor:pointer;
  padding-left:10px;
}
.userbox .list:hover,.storebox .list:hover{
  background-color:#eeeeee;
}
.yname{
  font-size: 13px;
  color: #444;
  margin-bottom:8px;
}
</style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12" style="margin-top:0px">
            <div class="layui-fluid">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header">渠道商户列表</div>
                            <div class="layui-card-body">
                                <div class="layui-btn-container" style="font-size:14px;">
                                    <!-- 搜索 -->
                                    <div class="layui-form" lay-filter="component-form-group" style="width:800px;display: inline-block;">
                                        <div class="layui-form-item" style="margin-left:5px;">
                                            <div class="layui-inline" style='margin-right:0'>
                                                <div class="layui-input-inline" style="width:300px">
                                                    <text class="yname">选择通道</text>
                                                    <select name="passway" id="passway" lay-filter="passway" lay-search></select>
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <button class="layui-btn layuiadmin-btn-list" lay-submit="" lay-filter="LAY-app-contlist-search" style="border-radius:5px;margin-top:20px;margin-bottom: 0;height:36px;line-height: 36px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                                </button>
                                              </div>
                                            <button class="layui-btn export" style="border-radius:5px;margin-top:20px;margin-bottom: 4px;height:36px;line-height: 36px;">导出</button>
                                        </div>
                                    </div>
                                </div>

                                <table class="layui-hide" id="test-table-page" lay-filter="test-table-page"></table>
                                <!-- 通道类型 -->
                                <script type="text/html" id="company">
                                    @{{#  if(d.company=='member'){ }}
                                    会员卡
                                    @{{#  } else if(d.company=='vbilla') { }}
                                    随行付A
                                    @{{#  } else if(d.company=='vbill') { }}
                                    随行付
                                    @{{#  } else if(d.company=='alipay') { }}
                                    支付宝
                                    @{{#  } else if(d.company=='weixin') { }}
                                    微信
                                    @{{#  } else if(d.company=='mybank') { }}
                                    快钱支付
                                    @{{#  } else if(d.company=='herongtong') { }}
                                    和融通
                                    @{{#  } else if(d.company=='newland') { }}
                                    新大陆
                                    @{{#  } else if(d.company=='fuiou') { }}
                                    富友
                                    @{{#  } else if(d.company=='jdjr') { }}
                                    京东聚合
                                    @{{#  } else if(d.company=='dlb') { }}
                                    哆啦宝
                                    @{{#  } else if(d.company=='zft') { }}
                                    花呗分期
                                    @{{#  } else if(d.company=='tfpay') { }}
                                    TF通道
                                    @{{#  } else if(d.company=='hkrt') { }}
                                    海科融通
                                    @{{#  } else if(d.company=='easypay') { }}
                                    易生
                                    @{{#  } else if(d.company=='hltx') { }}
                                    葫芦天下
                                    @{{#  } else if(d.company=='linkage') { }}
                                    联动优势
                                    @{{#  } else if(d.company=='lianfu') { }}
                                    工行
                                    @{{#  } else if(d.company=='changsha') { }}
                                    长沙银行
                                    @{{#  } else if(d.company=='lianfuyouzheng') { }}
                                    邮政
                                    @{{#  } else if(d.company=='pingan') { }}
                                    平安银行
                                    @{{#  } else if(d.company=='wftpay') { }}
                                    徽商银行
                                    @{{#  } else if(d.company=='lianfuyoupay') { }}
                                    邮储银行
                                    @{{#  } else if(d.company=='jiujiang') { }}
                                    九江银行
                                    @{{#  } else if(d.company=='nongjin') { }}
                                    农商行
                                    @{{#  } else if(d.company=='abc') { }}
                                    农行bmp通道
                                    @{{#  } else if(d.company=='unionpay_merch') { }}
                                    银联商务
                                    @{{#  } else if(d.company=='wingpay') { }}
                                    翼支付
                                    @{{#  } else if(d.company=='saobei') { }}
                                    扫呗
                                    @{{#  } else if(d.company=='abc_quiet') { }}
                                    农行静态码通道
                                    @{{#  } else if(d.company=='cool') { }}
                                    酷点
                                    @{{#  } else if(d.company=='hwcpay') { }}
                                    汇旺财
                                    @{{#  } else { }}
                                    @{{ d.company }}
                                    @{{#  } }}
                                </script>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<input type="hidden" class="user_id">
<input type="hidden" class="company_id">

<script src="{{asset('/layuiadmin/layui/layui.js')}}"></script>
<script>
var token = localStorage.getItem("Usertoken");
var str=location.search;
var store_id=str.split('?')[1];

layui.config({
    base: '../../layuiadmin/' //静态资源所在路径
}).extend({
    index: 'lib/index' //主入口模块
}).use(['index','form','table','laydate'], function(){
    var $ = layui.$
        ,admin = layui.admin
        ,form = layui.form
        ,table = layui.table
        ,laydate = layui.laydate;

    $('.store_id').val(store_id);

    // 未登录,跳转登录页面
    $(document).ready(function(){
        if(token==null){
        window.location.href="{{url('/user/login')}}";
        }
    });

    var s_storename=localStorage.getItem('s_storename');

    if(store_id == undefined){

    }else{
        $('.inputstore').val(s_storename);
    }

    // 选择通道
    $.ajax({
        url : "{{url('/api/user/store_open_pay_way_lists')}}",
        data : {token:token,l:100},
        type : 'post',
        dataType:'json',
        success : function(data) {
            var optionStr = "";
            for(var i=0;i<data.data.length;i++){
                optionStr += "<option value='" + data.data[i].company + "'>"
                + data.data[i].company_desc + "</option>";
            }
            $("#passway").append('<option value="">选择通道类型</option>'+optionStr);
            layui.form.render('select');
        },
        error : function(data) {
            alert('查找板块报错');
        }
    });

    // 渲染表格
    table.render({
        elem: '#test-table-page'
        ,url: ""
        ,method: 'post'
        ,where:{
            token:token
        }
        ,request:{
            pageName: 'p'
            ,limitName: 'l'
        }
        ,page: true
        ,cellMinWidth: 100
        ,cols: [[
            {field:'store_id',align:'center',title: '门店id'},
            {field:'store_name',align:'center',title: '门店名称'},
            {field:'mch_id',align:'center',title: '商户号'},
            {field:'people_phone',align:'center',title: '手机号码'},
            {field:'people',align:'center',title: '联系人'},
            {field:'name',align:'center',title: '所属代理'}
        ]]
        ,response: {
            statusName: 'status' //数据状态的字段名称，默认：code
            ,statusCode: 1 //成功的状态码，默认：0
            ,msgName: 'message' //状态信息的字段名称，默认：msg
            ,countName: 't' //数据总数的字段名称，默认：count
            ,dataName: 'data' //数据列表的字段名称，默认：data
        }
        ,done: function(res, curr, count){
//            console.log(res);
            $('th').css({'font-weight': 'bold', 'font-size': '15','color': 'black','background':'linear-gradient(#f2f2f2,#cfcfcf)'});	//进行表头样式设置
        }
    });

    table.on('tool(test-table-page)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
        var e = obj.data; //获得当前行数据
        var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
        var tr = obj.tr; //获得当前行 tr 的DOM对象
        //          console.log(e);
        // localStorage.setItem('s_store_id', e.store_id);

        // if(layEvent === 'tongbu'){ //同步
        //     $.post("{{url('/api/basequery/update_order')}}",
        //     {
        //         token:token
        //         ,store_id:e.store_id
        //         ,out_trade_no:e.out_trade_no
        //     },function(res){
        //         if(res.status==1){
        //             layer.msg(res.message, {
        //             offset: '50px'
        //             ,icon: 1
        //             ,time: 2000
        //             });
        //         }else{
        //             layer.msg(res.message, {
        //             offset: '50px'
        //             ,icon: 2
        //             ,time: 2000
        //             });
        //         }
        //     },"json");
        // }
    });

    // 选择通道类型
    form.on('select(passway)', function(data){
        var company_id = data.value;
        $('.company_id').val(company_id);
        // var pageLoading = layer.msg('数据请求中..', {
        //     icon: 16
        //     ,shade: 0.3
        //     ,time: false
        // });
        // //执行重载
        // table.reload('test-table-page', {
        //     where: {
        //         company:company_id
        //     }
        //     ,page: {
        //         curr: 1 //重新从第 1 页开始
        //     },
        //     done:function(res, curr, count){
        //         layer.close(pageLoading);
        //     }
        // });
    });

    form.on('submit(LAY-app-contlist-search)', function(data){
        var pageLoading = layer.msg('数据请求中..', {
            icon: 16
            ,shade: 0.3
            ,time: false
        });
        table.reload('test-table-page', {
            url: "{{url('/api/user/company_all_store_list')}}",
            method:'post',
            where: {
              company: $('.company_id').val(),
            }
            ,page: {
              curr: 1 //重新从第 1 页开始
            },
            done:function(res, curr, count){
                layer.close(pageLoading);
            }
         });
    });
    
    $('.export').click(function(){
        var exportLoading = layer.msg('数据请求中..', {
            icon: 16
            ,shade: 0.3
            ,time: false
        });
        let company = $('.company_id').val()
        if(!company){
            layer.msg('请选择通道！')
            return false
        }
        window.location.href="{{url('/api/user/company_all_store_list')}}"+"?token="+token+"&company="+company+"&export=1"
        layer.close(exportLoading);
        // $.ajax({
        //     url : "{{url('/api/user/company_all_store_list')}}",
        //     data : {
        //         token:token,
        //         company: $('.company_id').val(),
        //         export: 1
        //     },
        //     dataType:'json',
        //     type : 'post',
        //     success : function(data) {
        //         layer.close(exportLoading);
        //         if (data.status == 1) {
        //             layer.close(exportLoading);
        //             let urls = data.url.replace(/http:\/\//i, 'https://');
        //             window.location.href=urls;
        //         } else {
        //             layer.msg(data.message);
        //         }
        //     },
        //     error : function(data) {
        //         layer.close(exportLoading);
        //         alert('查找板块报错');
        //     }
        // });
    })

});

</script>

</body>
</html>
